import java.util.Scanner;

public class Demo14 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int y = scanner.nextInt();
        int m = scanner.nextInt();
        int d = scanner.nextInt();
        System.out.println(ana(y,m,d));
    }

    private static int ana(int y, int m, int d) {
        int n = 0;
        int[] month = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        if ((y % 400) == 0|| ((y % 4) == 0) && ((y % 100) != 0)){
            month[2] = 29;
        }
        for (int i = 0; i < m; i++) {
            n += month[i];
        }
        return n + d;
    }
}
